


putexcel set "Results\tab_B3\age40to49_table_eq", replace

putexcel B1 = "N (1,000s)"
putexcel B2 = "1980"
putexcel C2 = "2018"

putexcel D1 = "Sorting"
putexcel D2 = "1980"
putexcel E2 = "2018"
putexcel F2 = "Change"

putexcel G1 = "Gini, data"
putexcel G2 = "1980"
putexcel H2 = "2018"

putexcel I1 = "Gini (i)"
putexcel I2 = "2018"

putexcel J1 = "D Gini (i)/D Gini, data"



putexcel A3 = "Only ages 40 to 49"

clear
use "Results\tab_B3\Scenario_14\Sorting\results_ambition"

gen temp=male_1_marr+male_2_marr+male_3_marr+male_4_marr+female_1_marr+female_2_marr+female_3_marr+female_4_marr+male_1_sing+male_2_sing+male_3_sing+male_4_sing+female_1_sing+female_2_sing+female_3_sing+female_4_sing

qui sum temp if aar==1980
sca temp2=r(mean)/1000

putexcel B3 = temp2

qui sum temp if aar==2018
sca temp2=r(mean)/1000

putexcel C3 = temp2

drop temp

gen temp=s_1_1*(0*male_1+(1-0)*female_1)+s_2_2*(0*male_2+(1-0)*female_2)+s_3_3*(0*male_3+(1-0)*female_3)+s_4_4*(0*male_4+(1-0)*female_4)

qui sum temp if aar==1980
sca temp2=r(mean)

putexcel D3 = temp2

qui sum temp if aar==2018
sca temp3=r(mean)

putexcel E3 = temp3

sca temp4=(temp3-temp2)/temp2

putexcel F3 = temp4

drop temp

clear
use "Results\tab_B3\Scenario_14\Decomposition\results_eq"

qui sum gini if aar==1980
sca temp2=r(mean)

putexcel G3 = temp2

qui sum gini if aar==2018
sca temp3=r(mean)

putexcel H3 = temp3

qui sum gini_cf_sort if aar==2018
sca temp4=r(mean)

putexcel I3 = temp4

sca temp5=(temp4-temp2)/(temp3-temp2)

putexcel J3 = temp5

